import wx

class ChooseTestScript:
    """
    It is a component of ChooseScriptsPanel, it represents a script test
    selection.
    
    @author Danilo Torres
    """
    
    def __init__(self, id, emptySpace, textCtrl, browseButton, checkBox, removeButton):
        """
        Initialize ChooseTestScript.
        @param id: the test script component id
        @param emptySpace: an empty space just for layout
        @param textCtrl: a wx.TextCtrl where the user sets the test script
        @param browseButton: a wx.Button used to browse until the test script file
        @param checkBox: a wx.CheckBox which means that this test script is to be ran
        @param removeButton: a wx.Button used to remove this test scripts component from the parent panel.
        """
        self.id = id
        self.emptySpace = emptySpace
        self.textCtrl = textCtrl
        self.browseButton = browseButton
        self.checkBox = checkBox
        self.removeButton = removeButton
        
    def setTestPath(self, path):
        self.textCtrl.SetValue(path)
        self.textCtrl.SetInsertionPointEnd()
        
    def getTestPath(self):
        return self.textCtrl.GetValue()
        
    def isSelected(self):
        return self.checkBox.IsChecked()
    
    def select(self, isSelected):
        self.checkBox.SetValue(isSelected)
        
    def GetId(self):
        """
        @return: this component id.
        """
        return self.id
    
    def Destroy(self):
        """
        It destroys this test script component and all its dependents.
        """
        self.emptySpace.Destroy()
        self.textCtrl.Destroy()
        self.browseButton.Destroy()
        self.checkBox.Destroy()
        self.removeButton.Destroy()